// -----------------------------------------------
// Author:     code34 nicolas_boiteux@yahoo.fr
// Edited by:  Neumatic
// Warcontext: Teleport to MHQ
// -----------------------------------------------

private ["_vehicle","_position"];

_vehicle = wcteleport;

if (format ["%1", _vehicle] == "any") exitWith {hint "No respawn point avalaible"};

_position = (getPosATL _vehicle) findEmptyPosition [10, 300];
if (count _position == 0) then {
	diag_log "WARCONTEXT: CANNOT FIND EMPTY POSITION FOR RESPAWN POINT";
};

if ((alive _vehicle) and {((getPosATL _vehicle) distance _position < 100)}) then {
	if (leader(group player) == player) then {
		{
			if ((!isPlayer _x) and {(_x distance player < 50)}) then {
				_x setPos _position;
			};
		} foreach (units (group player));
	};
	player setPos _position;
} else {
	hint "No respawn point avalaible";
};